<?php
// 连接数据库
$host = "localhost";
$dbname = "db";
$username = "root";
$password = "123456";
$conn = new mysqli($host, $username, $password, $dbname);

if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}

$email = $_POST['email'];
$password = $_POST['password'];

// 查询用户
$sql = "SELECT * FROM users WHERE email='$email' AND password='$password'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    session_start();
    $row = $result->fetch_assoc();
    $_SESSION['user_id'] = $row['id'];
    header("Location: profile.php"); // 假设有一个dashboard页面
    exit();
} else {
    echo "错误：邮箱或密码错误";
}

$conn->close();
?>
<?php
// 目标页面的 URL
$targetUrl = "";
 
// 使用 header 函数进行重定向
header("Location: " . $targetUrl);
 
// 结束脚本执行
exit();
?>